/**
 * @license
 * Copyright 2024 The Model Explorer Authors. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ==============================================================================
 */

.container {
  position: relative;
  overflow: visible;
  background-color: var(--me-surface-color);
  border-radius: 99px;
  height: 30px;
  display: flex;
  align-items: center;
  padding: 0 8px;

  .input-container {
    display: flex;
    align-items: center;
    width: 250px;

    mat-icon.search,
    mat-icon.clear {
      color: var(--me-on-surface-variant-color);
      font-size: 20px;
      width: 20px;
      height: 20px;
      flex-shrink: 0;
    }

    mat-icon.clear {
      opacity: 0.85;
      cursor: pointer;

      &:hover {
        opacity: 1;
      }
    }

    input {
      height: 24px;
      border: none;
      outline: none;
      box-sizing: border-box;
      padding: 0 4px;
      font-size: 12px;
      flex-grow: 1;
      min-width: 0;
      background-color: transparent;
    }

    .btn-clear-container {
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .icon-container {
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      color: var(--me-on-surface-variant-color);
      opacity: 0.85;

      &:hover {
        opacity: 1;
      }

      mat-icon {
        font-size: 20px;
        width: 20px;
        height: 20px;
      }
    }
  }

  .input-container:has(input:focus) mat-icon.search {
    color: var(--me-primary-color);
  }

  .search-results-container {
    overflow: hidden;
    position: absolute;
    top: calc(100% + 12px);
    left: -4px;
    border: 1px solid var(--me-outline-variant-color);
    border-radius: 4px;
    width: 380px;
    display: flex;
    flex-direction: column;
    background-color: var(--me-surface-container-lowest-color);
    box-shadow: var(--me-bubble-shadow);

    .title-container {
      background-color: var(--me-surface-container-color);
      border-bottom: 1px solid var(--me-outline-hairline-color);
      box-sizing: border-box;
      padding: 0 10px 10px;
    }

    .title {
      height: 28px;
      min-height: 28px;
      font-size: 12px;
      display: flex;
      align-items: center;
      justify-content: space-between;

      .title-label {
        white-space: nowrap;
      }
    }

    .content {
      flex-grow: 1;
      min-height: 0;
      overflow-y: auto;
      padding-bottom: 6px;

      .empty-results {
        padding: 12px 8px 6px;
        display: flex;
        align-items: center;
        font-size: 12px;
        color: var(--me-on-surface-variant-color);
      }
    }

    .search-result-type-selector-container {
      display: flex;
      align-items: center;
      font-size: 12px;
      margin-top: 2px;

      .options-container {
        display: flex;
        align-items: center;
        gap: 6px;
      }

      .option-container {
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        user-select: none;
        border: 1px solid var(--me-outline-variant-color);
        padding: 4px 14px;
        border-radius: 6px;
        background-color: var(--me-surface-color);
        color: var(--me-on-surface-variant-color);

        &.selected {
          border-color: var(--me-secondary-container-color);
          background-color: var(--me-secondary-container-color);
          color: var(--me-on-surface-color);

          mat-icon {
            color: var(--me-on-surface-color);
          }
        }

        .icon-container {
          width: 18px;
          height: 18px;
          display: flex;
          align-items: center;
          justify-content: center;
          box-sizing: border-box;
          margin-right: 4px;
        }

        mat-icon {
          font-size: 16px;
          width: 16px;
          height: 16px;
          color: var(--me-on-surface-variant-color);
        }

        .option-label {
          font-size: 12px;
          font-family: 'Google Sans Text', Arial, Helvetica, sans-serif;
          letter-spacing: normal;
        }
      }
    }
  }

  .footer {
    height: 32px;
    min-height: 32px;
    background-color: var(--me-surface-container-color);
    border-top: 1px solid var(--me-outline-hairline-color);
    box-sizing: border-box;
    padding: 0 10px;
    font-size: 12px;
    display: flex;
    align-items: center;
    color: var(--me-on-surface-variant-color);

    mat-icon {
      font-size: 16px;
      height: 16px;
      width: 16px;
      color: var(--me-on-surface-variant-color);
      margin-right: 4px;
    }
  }

  .no-matches {
    position: absolute;
    top: calc(100% + 12px);
    left: -4px;
    color: var(--me-on-surface-variant-color);
    padding: 8px;
    border: 1px solid var(--me-outline-hairline-color);
    border-radius: 4px;
    background-color: var(--me-surface-container-color);
    font-size: 12px;
    box-shadow: var(--me-bubble-shadow);
  }
}

::ng-deep .model-explorer-search-help-popup {
  padding: 12px;
  font-size: 12px;
  color: var(--me-on-surface-color);
  background-color: var(--me-surface-container-low-color);

  ul {
    margin-block-end: 0;
  }

  .code {
    display: inline-block;
    background-color: var(--me-surface-container-high-color);
    font-family: monospace;

    &.regex {
      background-color: var(--me-warning-container-color);
    }
  }
}
